<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title></title>
<style type="text/css">
    .outer{
        width:300px;
        height: 40px;
        background:#eee ;
    }
    .inner{
        width: 0;
        height: 40px;
        background: red;
    }
</style>
</head>
<body>
<div class="outer">
    <div class="inner"></div>
</div>
<script type="text/javascript">
    var oInner=document.getElementsByClassName('inner')[0]
    var i=0
    var timer=setInterval(function(){
        i++
        if(i==100){
            clearInterval(timer)
        }
        oInner.style.width=i+"px"
    },20)


</script>
</body>
</html>
